package com.erlang.spring.controller;

import com.erlang.spring.service.LifecycleService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Description：客户端
 */
public class ClientController {

    /**
     * ApplicationContext:spring-IOC容器
     * ClassPathXmlApplicationContext：容器实现类，加载配置文件
     * applicationContext.getBean：获得容器中的bean对象
     */
    @Test
    public void createAccount(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("bean.xml");
        System.out.println("applicationContext初始化完成");
        LifecycleService lifecycleService = applicationContext.getBean("lifecycleService", LifecycleService.class);
        lifecycleService.doJob();
        System.out.println("applicationContext容器关闭");
        ((ClassPathXmlApplicationContext) applicationContext).close();

    }
}